﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Marmat.Forms.Skin
{
    /// <summary>
    /// Breadcrumb 的集合
    /// </summary>
    public class BreadcrumbItemCollection : ControlItemCollection<BreadcrumbItem>
    {
        /// <summary>
        /// Breadcrumb 的集合
        /// </summary>
        /// <param name="control"></param>
        public BreadcrumbItemCollection(Control control) : base(control)
        {

        }

        public override void Add(BreadcrumbItem item)
        {
            if (string.IsNullOrEmpty(item.Name))
                item.Name = nameof(BreadcrumbItem) + (base.Count + 1);
            base.Add(item);

        }

        public bool IsLast(BreadcrumbItem item)
        {
            int index = base.IndexOf(item);
            return index == base.Count - 1;
        }
    }
}
